package com.nursing.service;

import com.nursing.Dao.DutyScheduleDao;
import com.nursing.bean.DutySchedule;
import com.nursing.model.dto.DutyDto;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DutyService {
    private final DutyScheduleDao dutyScheduleDao;

    public DutyService(DutyScheduleDao dutyScheduleDao) {
        this.dutyScheduleDao = dutyScheduleDao;
    }

    public List<DutyDto> getDutyList(Integer nurseId) {
        if(nurseId == null){
            return dutyScheduleDao.getDutyList();
        }
        return dutyScheduleDao.getDutyListByNurseId(nurseId);
    }

    public void editStatus(Integer id, Integer status) {
        DutySchedule dutySchedule = new DutySchedule();
        dutySchedule.setId(id);
        dutySchedule.setStatus(status);
        dutyScheduleDao.editStatus(dutySchedule);
    }

    public void addDutySchedule(DutySchedule dutySchedule) {
        dutyScheduleDao.addDutySchedule(dutySchedule);
    }

    public void deleteDutySchedule(int id) {
        dutyScheduleDao.deleteDutySchedule(id);
    }

}
